Refactor route_head to move functonality from old functions to ctor/dtors.
authortsteven4@gmail.com <tsteven4@gmail.com@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sat, 15 Feb 2014 21:19:33 +0000 (21:19 +0000)
committertsteven4@gmail.com <tsteven4@gmail.com@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sat, 15 Feb 2014 21:19:33 +0000 (21:19 +0000)
git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4743 f51c46e8-681c-474f-0cfe-069cfd0219fb

gpsbabel/defs.h
gpsbabel/route.cc

index 2a6fe5817c8915e1d3fef83022db9508b3bf5467..8e918270925bde5ea33d3afa64f58c2790154647 100644 (file)
@@ -561,18 +561,6 @@ public:
 class route_head
 {
 public:
-  route_head() :
-#if NEW_STRINGS
-#else
-    rte_name(NULL),
-    rte_desc(NULL),
-#endif
-    rte_num(0),
-    rte_waypt_ct(0),
-    fs(NULL),
-    cet_converted(0),
-    line_width(-1),
-    session(NULL) {}
   queue Q;             /* Link onto parent list. */
   queue waypoint_list; /* List of child waypoints */
   String rte_name;
@@ -585,6 +573,10 @@ public:
   gb_color line_color;         /* Optional line color for rendering */
   int line_width;         /* in pixels (sigh).  < 0 is unknown. */
   session_t* session;  /* pointer to a session struct */
+
+public:
+  route_head();
+  ~route_head();
 };
 
 /*
index ab7f754015e336ddf1299a26f798ba003c544b02..d58ea11e11ccf95217c041f6c95d181290757e1f 100644 (file)
@@ -68,24 +68,16 @@ route_head*
 route_head_alloc(void)
 {
   route_head* rte_head = new route_head;
-  QUEUE_INIT(&rte_head->Q);
-  QUEUE_INIT(&rte_head->waypoint_list);
-  rte_head->session = curr_session();
   return rte_head;
 }
 
 static void
 any_route_free(route_head* rte)
 {
-  waypt_flush(&rte->waypoint_list);
-  if (rte->fs) {
-    fs_chain_destroy(rte->fs);
-  }
   delete rte;
   rte = NULL;
 }
 
-
 static void
 any_route_add_head(route_head* rte, queue* head)
 {
@@ -698,3 +690,31 @@ void track_recompute(const route_head* trk, computed_trkdata** trkdatap)
     xfree(tdata);
   }
 }
+
+route_head::route_head() :
+  // Q(),
+  // waypoint_list(),
+#if !NEW_STRINGS
+  rte_name(NULL),
+  rte_desc(NULL),
+#endif
+  // rte_url(),
+  rte_num(0),
+  rte_waypt_ct(0),
+  fs(NULL),
+  cet_converted(0),
+  // line_color(),
+  line_width(-1),
+  session(curr_session())
+{
+  QUEUE_INIT(&Q);
+  QUEUE_INIT(&waypoint_list);
+};
+
+route_head::~route_head()
+{
+  waypt_flush(&waypoint_list);
+  if (fs) {
+    fs_chain_destroy(fs);
+  }
+}